#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;

int GetLuckNum(vector<int>& Xi, int n, int pos, int sum, int mul)
{
    int luckcnt = 0;
    for(int i = pos; i < n; ++i){
        sum += Xi[i];
        mul *= Xi[i];
        if(sum > mul){
            luckcnt += 1 + GetLuckNum(Xi, n, i+1, sum, mul);
        }else if(Xi[i] == 1){
            luckcnt += GetLuckNum(Xi, n, i+1, sum, mul);
        }
        else{
            break;//回到上一层
        }
        sum -= Xi[i];
        mul /= Xi[i];
        while(i<n-1 && Xi[i]==Xi[i+1]){ ++i; }
    }
    return luckcnt;
}
int main()
{
    int n;
    cin >> n;
    if(n < 1 || n > 1000)
        return 0;
    vector<int> Xi(n);
    for(int i = 0; i < n; ++i){
        cin >> Xi[i];
    }
    
    sort(Xi.begin(), Xi.end());
    cout << GetLuckNum(Xi, n, 0, 0, 1);
    return 0;
}
